/*******************************************************************************
 * Copyright (c) 2010 Marcelo Cataldo, Sangeeth Nambiar
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * GraphControlsViewPart.java
 * 
 * View part for the graph controls
 * 
 * Contributors:
 *    Marcelo Cataldo  - initial implementation 
 *    Sangeeth Nambiar - initial implementation
 *******************************************************************************/
package edu.cmu.isr.dinvenio.ui.views;

import java.awt.Panel;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.part.ViewPart;

public class GraphControlsViewPart extends ViewPart {

	public Composite parent;
	private java.awt.Frame awtFrame;
	public Panel awtPanel;

	public GraphControlsViewPart() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void createPartControl(Composite parent) {
		this.parent = parent;	
 	    
		RowLayout l = new RowLayout(SWT.VERTICAL);
		l.fill = true;
		this.parent.setLayout(l);
 	      
		GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		
		Group controlsGroup = new Group(parent, SWT.NONE);
		controlsGroup.setText("AWT Controls");	
		controlsGroup.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		Composite awtContainer = new Composite(controlsGroup, SWT.EMBEDDED);	
		awtFrame = SWT_AWT.new_Frame(awtContainer);
		awtPanel = new java.awt.Panel();
		awtFrame.add(awtPanel, java.awt.BorderLayout.CENTER);
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}
	
	@SuppressWarnings("deprecation")
	public void refresh(){
		parent.layout(true);
		awtFrame.show();
	}
	public void disposeWidgets(){
		awtPanel.removeAll();
	}

}
